package com.pxst.dashboard.mapper;

import com.pxst.dashboard.resp.CountAndAmount;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * @author rj
 * @create 2023-11-02-17:17
 */
@Mapper
public interface InfoMapper {

    /**
     * 获取表中对应币种的等待的数量和金额
     * @param table 表明
     * @param currency 币种
     * @return
     */
    @Select("SELECT COUNT(*) count, SUM(request_amount) amount\n" +
            "        FROM  ${table}\n" +
            "        WHERE `status` IN (1, 2) AND currency = #{currency}")
    CountAndAmount sumProcessingTransactions(String table, String currency);

    /**
     * 获取代付表中对应币种的待审核的数量和金额
     * @param currency
     * @param confirmAccname
     * @return
     */
    @Select("SELECT COUNT(*) count, SUM(request_amount) amount\n" +
            "FROM sys_fo_order_main\n" +
            "WHERE `status` IN (1,2) AND currency = #{currency} AND confirm_accname = #{confirmAccname}")
    CountAndAmount sumConfirmableTransactions(String currency, Integer confirmAccname);

    /**
     * 获取外传表中对应币种的待审核的数量和金额
     * @param currency
     * @return
     */
    @Select("SELECT COUNT(*) count, SUM(request_amount) amount\n" +
            "FROM sys_et_order\n" +
            "WHERE `status` = 9 AND currency = #{currency}")
    CountAndAmount sumApprovalExternal(String currency);
}
